<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        var money = 1000;
        var count = 0;
        while (money < 5000) {
            money *= 1.05;
            count++;
        }
        console.log(money);
        console.log("一共需要" + count + "年");
    </script>
</body>

</html>